package yf.mall.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yf.annotation.SysLog;
import java.util.Map;
import com.yf.consts.DaoConst;
import yf.mall.entity.LogRuleEntity;
import yf.mall.service.LogRuleService;
import com.yf.response.R;


/**
 * 物流费规则Controller
 *
 * @author hxf
 * @email 505860922@qq.com
 * @date Tue Nov 05 11:24:09 CST 2019
 */
@RestController
@RequestMapping("/log/rule")
public class LogRuleController {
    @Autowired
    private LogRuleService logRuleService;

    /**
     * 列表物流费规则
     */
    @RequestMapping("/list")
    @RequiresPermissions("log:rule:list")
    public R list(@RequestParam Map<String,Object> params) {
        PageHelper.startPage(DaoConst.getPage(params),DaoConst.getLIMIT(params));
        List<LogRuleEntity> logRuleList = logRuleService.queryList(params);
        return R.ok(new PageInfo(logRuleList));
    }

    /**
     * 查看物流费规则
     */
    @SysLog("查看物流费规则")
    @RequestMapping("/info/{id}")
    @RequiresPermissions("log:rule:info")
    public R info(@PathVariable("id") Long id) {
        LogRuleEntity logRule = logRuleService.get(id);

        return R.ok(logRule);
    }

    /**
     * 保存物流费规则
     */
    @SysLog("保存物流费规则")
    @RequestMapping("/save")
    @RequiresPermissions("log:rule:save")
    public R save(LogRuleEntity logRule) {
        logRuleService.save(logRule);

        return R.ok(logRule);
    }

    /**
     * 修改物流费规则
     */
    @SysLog("修改物流费规则")
    @RequestMapping("/update")
    @RequiresPermissions("log:rule:update")
    public R update(LogRuleEntity logRule) {
        logRuleService.update(logRule);

        return R.ok(logRule);
    }

    /**
     * 删除物流费规则
     */
    @SysLog("删除物流费规则")
    @RequestMapping("/delete")
    @RequiresPermissions("log:rule:delete")
    public R delete(Long[]ids) {
        logRuleService.deleteBatch(ids);

        return R.ok();
    }

    /**
     * 所有物流费规则
     */
    @SysLog("所有物流费规则")
    @RequestMapping("/queryAll")
    public R queryAll (@RequestParam Map<String,Object> params) {

        List<LogRuleEntity> logRuleList = logRuleService.queryList(params);

        return R.ok(logRuleList);
    }

    /**
    @ModelAttribute
    public SearchParam<LogRuleEntity> searchParam(SearchParam<LogRuleEntity> params, LogRuleEntity logRule) {
        if (logRule != null) {
            params.setEntity(logRule);
        }

        return params;
    }
 **/
    /***********自定义开始***********/
}
